//
//  NQLeftMenuHeaderView.m
//  ZLFastDoctor
//
//  Created by 李岚清 on 16/5/22.
//  Copyright © 2016年 LS. All rights reserved.
//

#import "NQLeftMenuHeaderView.h"
#define MAS_SHORTHAND
#define MAS_SHORTHAND_GLOBALS
#import <Masonry/Masonry.h>

@interface NQLeftMenuHeaderView ()



@end

@implementation NQLeftMenuHeaderView

#pragma mark - set/get

#pragma mark - 重写构造方法
- (instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        [self setupUI];
    }
    return self;
}

- (instancetype)initWithCoder:(NSCoder *)aDecoder{
    if (self = [super initWithCoder:aDecoder]) {
        [self setupUI];
    }
    return self;
}

#pragma mark - 添加子控件及约束
- (void)setupUI{
    //添加到view自身上
    [self addSubview:self.iconView];
    [self addSubview:self.nameLabel];
    [self addSubview:self.baseInfoLabel];
    //设置约束
    [self.iconView makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(30);
        make.top.equalTo(self).offset(20);
        make.width.height.equalTo(60);
    }];
    [self.nameLabel makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.iconView.right).offset(15);
        make.top.equalTo(self.iconView);
    }];
    [self.baseInfoLabel makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.iconView.right).offset(15);
        make.bottom.equalTo(self.iconView);
    }];
    
    //添加点按手势
    self.userInteractionEnabled = YES;
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(settingUserInfo)];
    [self addGestureRecognizer:tap];
    
}

//加载个人信息
- (void)settingUserInfo{
//    NSLog(@"加载个人信息");
    if ([self.delegate respondsToSelector:@selector(leftMenuHeaderViewSettingUserInfo:)]) {
        [self.delegate leftMenuHeaderViewSettingUserInfo:self];
    }
}

#pragma mark - 懒加载子控件
- (UIImageView *)iconView{
    if (!_iconView) {
        _iconView = [[UIImageView alloc] init];
        _iconView.image = [UIImage imageNamed:@"name"];
        _iconView.layer.cornerRadius = 30;
        _iconView.layer.masksToBounds = YES;
    }
    return _iconView;
}

- (UILabel *)nameLabel{
    if (!_nameLabel) {
        _nameLabel = [[UILabel alloc] init];
        _nameLabel.text = @"凤凰涅槃";
        _nameLabel.font = [UIFont systemFontOfSize:18];
        _nameLabel.textColor = [UIColor whiteColor];
    }
    return _nameLabel;
}

- (UILabel *)baseInfoLabel{
    if (!_baseInfoLabel) {
        _baseInfoLabel = [[UILabel alloc] init];
        _baseInfoLabel.text = @"基本资料信息";
        _baseInfoLabel.font = [UIFont systemFontOfSize:16];
        _baseInfoLabel.textColor = [UIColor whiteColor];
    }
    return _baseInfoLabel;
}

@end
